/****************************************************
文件：StrategyModel.cs
作者：UnitySir
邮箱：zouajck@foxmail.com
日期：2021/05/05 09:59:23
功能：Nothing
*****************************************************/

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class StrategyModel : MonoBehaviour
{
    private void Start()
    {
        StrategyContext context = new StrategyContext();
        context.Strategy = new ConcreteStrategyA();
        context.Call();
    }
}

public class StrategyContext
{
    private IStrategy mStrategy;

    public IStrategy Strategy
    {
        get => mStrategy;
        set => mStrategy = value;
    }

    public void Call()
    {
        mStrategy?.Call();
    }
}

public interface IStrategy
{
    void Call();
}

public class ConcreteStrategyA : IStrategy
{
    public void Call()
    {
        Debug.Log("Use ConcreteStrategyA");
    }
}

public class ConcreteStrategyB : IStrategy
{
    public void Call()
    {
        Debug.Log("Use ConcreteStrategyB");
    }
}

public class ConcreteStrategyC : IStrategy
{
    public void Call()
    {
        Debug.Log("Use ConcreteStrategyC");
    }
}